package com.xiaoxu.intranetweb.mybatisplusSzappdb.controller.ashGate;


import com.xiaoxu.intranetweb.mybatisplusSzappdb.business.ashGate.MaterialLevelQueryBu;
import com.xiaoxu.intranetweb.util.PermissionCheck;
import com.xiaoxu.intranetweb.util.SzResult;
import io.netty.handler.codec.http.HttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 料位查询控制器
 * @author xiaoxu
 * @date 2022/1/5 15:00
 * @version 1.0
 * @since 1.0
 */
@CrossOrigin()
@RestController
@RequestMapping(value="/ashGate")
public class MaterialLevelQueryController {
    @Autowired
    private MaterialLevelQueryBu materiallevelQueryBu;
    /**
     * 料位查询接口
     * @return SzResult
     */
    @GetMapping("/getMateriallevel")
    public SzResult getMateriallevel(HttpServletRequest request) {
        String plantId =request.getHeader("Plant-Id");
        return materiallevelQueryBu.getMateriallevel(plantId);
    }
//    获取石粉料位
    /**
     * 料位查询接口
     * @return SzResult
     */
    @GetMapping("/getStoneMateriallevel")
    public SzResult getStoneMateriallevel(HttpServletRequest request) {
        String plantId =request.getHeader("Plant-Id");
        return materiallevelQueryBu.getStoneMateriallevel(plantId);
    }

//    获取石粉料位更新记录
//@GetMapping("/getStoneMateriallevelTable")
//public SzResult getStoneMateriallevelTable(@RequestParam(required = false) String startTime,@RequestParam(required = false)String endTime, HttpServletRequest request) {
//    String plantId =request.getHeader("Plant-Id");
//    return materiallevelQueryBu.getStoneMateriallevel(plantId);
//}
    //石粉料位更新记录
    @GetMapping("/getStoneMateriallevelRecord")
    public SzResult getStoneMateriallevelUpdate( @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "pageSize", required = false) Integer pageSize,@RequestParam(value = "stoneId", required = false) String stoneId, @RequestParam(value = "startTime", required = false) String startTime, @RequestParam(value = "endTime", required = false) String endTime, HttpServletRequest request) {
        String plantId = request.getHeader("Plant-Id");
        return materiallevelQueryBu.getStoneMateriallevelRecord(page,pageSize,startTime,endTime,stoneId,plantId);
    }

//    石粉t_pi_stone表的增删改查
    @GetMapping("/getPiStones")
    public SzResult getPiStones(@RequestParam(value = "pageNum", required = false) Integer pageNum, @RequestParam(value = "pageSize", required = false) Integer pageSize,@RequestParam(value = "stoneId", required = false) String stoneName,HttpServletRequest request) {
        String plantId = request.getHeader("Plant-Id");
        return materiallevelQueryBu.getPiStones(pageNum,pageSize,stoneName,plantId);
    }

//    拿到石粉t_pi_stone表所有数据
    @GetMapping("/getAllPiStones")
    public SzResult getAllPiStones(@RequestParam(value = "stoneId", required = false) String stoneName,HttpServletRequest request) {
        String plantId = request.getHeader("Plant-Id");
        return materiallevelQueryBu.getAllPiStones(stoneName,plantId);
    }

}
